﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using DevExpress.UserSkins;
using DevExpress.XtraBars.Helpers;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Ribbon.Gallery;
using System.Threading;
using System.Globalization;


namespace QLTV
{
    public partial class frmMain : RibbonBase
    {
        public frmMain()
        {
         
            InitializeComponent();
           // rpgDuLieu.Visible = MyPermissionPerForm.TruyCap;
            // xtraTabbedMdiManager1.MdiParent = this;
            //this.ShowInTaskbar = false;
            //this.WindowState = FormWindowState.Minimized;
            //this.Hide();

        }

        private void Main_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'hRManagementDataSet.tblPhongBan' table. You can move, or remove it, as needed.

            GalleryDropDown g = new GalleryDropDown();
            g.Ribbon = ribbon;
            DevExpress.XtraBars.Helpers.SkinHelper.InitSkinGalleryDropDown(g);
            btnSkinSelector.DropDownControl = g;
            //SkinSelector
            // loadDanhMuc();
            DevExpress.LookAndFeel.UserLookAndFeel.Default.StyleChanged += Default_StyleChanged;
           loadBanLamViec();

            //Thread.Sleep(10000);
            //this.ShowInTaskbar = true;
            //this.WindowState = FormWindowState.Maximized;
            //this.Show();

        }
        private void Default_StyleChanged(object sender, EventArgs e)
        {
             QLTV.Database.dsUsersTableAdapters.tblUserProfileTableAdapter tadProfile = new Database.dsUsersTableAdapters.tblUserProfileTableAdapter();
             tadProfile.setDefautTheme(DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName, Program.username);
             
        }
        private void loadBanLamViec()
        {
            Forms.frmBanLamViec f = new Forms.frmBanLamViec();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            lblDateTime.Caption = "Bây giờ là: " + (DateTime.Now.ToString("h:mm:ss tt, dd/MM/yyyy"));
        }

        private void btnDanhMuc_ItemClick(object sender, ItemClickEventArgs e)
        {


        }

        private void btnDanhSachNhanVien_ItemClick(object sender, ItemClickEventArgs e)
        {
            //Forms.HoSoNhanSu.frmDanhSachNhanSu f = new Forms.HoSoNhanSu.frmDanhSachNhanSu();
            //for (int i = 0; i < this.MdiChildren.Length; i++)
            //{
            //    if (f.Name == this.MdiChildren[i].Name)
            //    {
            //        this.MdiChildren[i].Activate();
            //        return;
            //    }
            //}
            //f.MdiParent = this;
            //f.Show();
        }

        private void btnThongTinCongTy_ItemClick(object sender, ItemClickEventArgs e)
        {
            //frmToChuc f = new frmToChuc();
            //f.Show();
        }

        private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void btnPhanQuyen_ItemClick(object sender, ItemClickEventArgs e)
        {
            frmPhanQuyen f = new frmPhanQuyen();
            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void btnBanLamViec_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
        {
            loadDanhMuc();
        }
        private void loadDanhMuc()
        {
            Forms.frmDanhMuc f = new Forms.frmDanhMuc();
            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void btnNguoiDung_ItemClick(object sender, ItemClickEventArgs e)
        {
            Forms.BaoMat.frmUserList f = new Forms.BaoMat.frmUserList();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();

        }

        private void nbiVessel_ItemChanged(object sender, EventArgs e)
        {
            Forms.KhaiBao.frmVessel f = new Forms.KhaiBao.frmVessel();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void nbiVessel_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.KhaiBao.frmVessel f = new Forms.KhaiBao.frmVessel();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void nbiVesselType_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.KhaiBao.frmVesselType f = new Forms.KhaiBao.frmVesselType();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void nbiFlag_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.KhaiBao.frmFlag f = new Forms.KhaiBao.frmFlag();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void nbiEngine_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            //Forms.KhaiBao.frmEngine f = new Forms.KhaiBao.frmEngine();

            //for (int i = 0; i < this.MdiChildren.Length; i++)
            //{
            //    if (f.Name == this.MdiChildren[i].Name)
            //    {
            //        this.MdiChildren[i].Activate();
            //        return;
            //    }
            //}
            //f.MdiParent = this;
            //f.Show();
        }

        private void nbiEngineMaker_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.KhaiBao.frmEngineMaker f = new Forms.KhaiBao.frmEngineMaker();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void nbiEngineType_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.KhaiBao.frmEngineType f = new Forms.KhaiBao.frmEngineType();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void nbiThuyenVien_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.KhaiBao.frmCrewList f = new Forms.KhaiBao.frmCrewList();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void btnDangXuat_ItemClick(object sender, ItemClickEventArgs e)
        {
            Application.Restart();
        }

        private void ribbon_Click(object sender, EventArgs e)
        {

        }

        private void navBarItem2_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.KhaiBao.frmCrewList f = new Forms.KhaiBao.frmCrewList();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void navBarItem6_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.KhaiBao.frmVessel f = new Forms.KhaiBao.frmVessel();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void nbiGroupVessel_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.KhaiBao.frmGroupVessel f = new Forms.KhaiBao.frmGroupVessel();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void nbiCertificate_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.KhaiBao.frmCertificatecs f = new Forms.KhaiBao.frmCertificatecs();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void nbiCertificateCrew_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.KhaiBao.frmCertificateCrew f = new Forms.KhaiBao.frmCertificateCrew();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void nbiTrainingCourse_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.KhaiBao.frmTrainingCourse f = new Forms.KhaiBao.frmTrainingCourse();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void nbiTrainingCrew_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.KhaiBao.frmTrainingCrew f = new Forms.KhaiBao.frmTrainingCrew();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void nbiRanhk_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            
        }

        private void nbiRanhk_LinkClicked_1(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
Forms.KhaiBao.frmRank f = new Forms.KhaiBao.frmRank();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

        private void nbi_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {

        }

        private void navBarItem7_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            Forms.frmBanLamViec f = new Forms.frmBanLamViec();

            for (int i = 0; i < this.MdiChildren.Length; i++)
            {
                if (f.Name == this.MdiChildren[i].Name)
                {
                    this.MdiChildren[i].Activate();
                    return;
                }
            }
            f.MdiParent = this;
            f.Show();
        }

    }
}
